﻿
using Irony.Compiler;

namespace IronLua.Ast {

	public class ElseIfClause : Clause {

		readonly Expression condition;
		readonly BlockStatement then;

		public Expression Condition {
			get { return condition; }
		}

		public BlockStatement Then {
			get { return then; }
		}

		public override LuaNodeType  NodeType {
			get { return LuaNodeType.ElseIfClause; }
		}

		public ElseIfClause (CompilerContext context, NonTerminal nonTerminal, SourceLocation location, AstNodeList childNodes)
			: base (context, nonTerminal, location, childNodes)
		{
			condition = childNodes [1].ToExpression ();
			then = childNodes [3].To<BlockStatement> ();
		}

		public override void Accept (ILuaAstVisitor visitor)
		{
			visitor.VisitElseIfClause (this);
		}
	}
}
